<?php

namespace App\Repositories\Api;

use App\Models\Report;

class ReportRepository
{
    /**
     * 举报
     * @param null $params
     */
    public function addReport($params = null)
    {
        $data['object_type'] = $params['object_type'];
        $data['object_id'] = intval($params['object_id']);
        $data['type'] = intval($params['type']);
        $data['uid'] = intval($params['wechat_admin_id']);
        if (Report::where($data)->where("create_time", ">=", strtotime("-30 minutes"))->count("id")) {
            return retFail("请不要频繁举报");
        }

        $res = Report::create($data);
        return retSuc(['id' => $res['id']]);
    }

}


